"use strict";
/**
 * 使用QQ地图标注位置,参看demo的plat.html
 */
var map, marker, geocoder;
$(function () {
    var center = new qq.maps.LatLng(36.6853, 116.996907);
    var level = 7;
    if ($('#latitude').val() != '') {
        center = new qq.maps.LatLng($('#latitude').val(), $('#longitude').val());
        level = 10;
    }
    map = new qq.maps.Map(document.getElementById('platContainer'), {
        center: center,
        zoom: level
    });
    marker = new qq.maps.Marker({
        position: center,
        draggable: true,
        map: map
    });
    qq.maps.event.addDomListener(marker, 'dragend', function (event) {
        var pos = marker.getPosition();
        $('#latitude').val(pos.getLat());
        $('#longitude').val(pos.getLng());
    });
});

function searchMap(address) {
    addressConvertLocation(address, function (res) {
        $('#latitude').val(res.location.lat);
        $('#longitude').val(res.location.lng);
        var pos = new qq.maps.LatLng($('#latitude').val(), $('#longitude').val());
        map.setCenter(pos);
        marker.setPosition(pos);
    });
}